﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: FZH
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;
using FriendStar.Code;
using FriendStar.Domain.Entity.BOM;
using FriendStar.Domain.IRepository.BOM;
using FriendStar.Repository.BOM;

namespace FriendStar.Application.BOM
{
    /// <summary>
	/// 数据视图 V_PLM_CP_WGCP_GX 对应的数据应用功能类。
	/// </summary>
	public class V_PLM_CP_WGCP_GXApp
    {       
        private string UseUnit = Configs.GetValue("UseUnit");  

        private IV_PLM_CP_WGCP_GXRepository service = new V_PLM_CP_WGCP_GXRepository();

        public List<V_PLM_CP_WGCP_GXEntity> GetList(Pagination pagination, string number, string name, string assemble, string make)
        {
            var expression = ExtLinq.True<V_PLM_CP_WGCP_GXEntity>();
            if (!string.IsNullOrEmpty(number))
            {
                expression = expression.And(t => t.DH.Contains(number));
            }
            if (!string.IsNullOrEmpty(name))
            {
                expression = expression.And(t => t.MC.Contains(name));
            }
            if (!string.IsNullOrEmpty(assemble))
            {
                expression = expression.And(t => t.AssembleLine.Contains(assemble));
            }
            if (!string.IsNullOrEmpty(make))
            {
                expression = expression.And(t => t.MakeLine.Contains(make));
            }
            return service.FindList(expression, pagination);
        }

        public V_PLM_CP_WGCP_GXEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }

        public V_PLM_CP_WGCP_GXEntity GetItem(string dh)
        { 
            var expression = ExtLinq.True<V_PLM_CP_WGCP_GXEntity>();
            if (!string.IsNullOrEmpty(dh))
            {
                expression = expression.And(t => t.DH == dh);
            }
            return service.FindEntity(expression);
        }
    }
}